package com.callbox.frontend;

import com.callbox.R;

import android.app.Activity;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.RemoteViews;

public class MessageNotification {
	
	private Context mContext;
	private NotificationManager mNotificationManager;
	//private SharedPreferences mSharedPreferences;
	
	public MessageNotification(Context context) {
		mContext = context;
		mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		//mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
	}

	private static final int MESSAGE_ID = 2;	
	
	public void createMessageNotification()  {
					
		//NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
	
		Notification notification = new Notification(R.drawable.ic_launcher, "Hello", System.currentTimeMillis());
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		//notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS;
		
		RemoteViews contentView = new RemoteViews("com.callbox.frontend", R.layout.message_notification);
		contentView.setImageViewResource(R.id.iContact, R.drawable.default_user);
		contentView.setTextViewText(R.id.txtTitle, "Custom notification");
		contentView.setTextViewText(R.id.txtDetail, "This is a custom layout");
		notification.contentView = contentView;
		
		Intent notificationIntent = new Intent(mContext, MessageNotificationReceiver.class);
		PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, notificationIntent, 0);
		notification.contentIntent = contentIntent;
		
		mNotificationManager.notify(MESSAGE_ID, notification);
	}
}
